<template>
  <div>
    <GTable ref="table" api="/v1/plApiRequestLog/selectPlApiRequestLogList" :columnSource="baseColumns" :hasEdit="true" :cbFun="cbFun" :otherHeight="-36" @setdialog="setdialog" />

    <el-dialog :title="dialogModule.title" :visible.sync="dialogModule.flag" center v-dialogDrag width="720px">
      <div v-tit="'日志报文信息'">
        <GForm ref="detail" :config="formConfig" disabled v-model="form"></GForm>
      </div>
      <span slot="footer">
        <el-button type="primary" @click="dialogModule.flag = false">确定</el-button>
        <el-button @click="dialogModule.flag = false">取消</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: 'log',
  data() {
    return {
      tableSelectData: [],
      dialogModule: {
        loading: false,
        flag: false,
        title: '',
        data: null,
        type: ''
      },
      form: {
        logNo: null,
        requestContent: null,
        responseContent: null
      }
    }
  },
  computed: {
    baseColumns() {
      return [
        {
          label: '日志流水号',
          prop: 'logNo',
          input: 'input'
        },
        {
          label: '日志关键字段',
          prop: 'logkey',
          input: 'input'
        },
        {
          label: '请求公司名称',
          prop: 'requestCompanyName',
          input: 'input'
        },
        {
          label: '请求应用名称',
          prop: 'requestApplicationName',
          input: 'input',
        },
        {
          label: '应用环境名称',
          prop: 'requestEnvironmentName',
          input: 'input'
        },
        {
          label: '接收公司名称',
          prop: 'responseCompanyName',
          input: 'input'
        },
        {
          label: '接收应用名称',
          prop: 'responseApplicationName',
          input: 'input'
        },
        {
          label: '接收应用环境名称',
          prop: 'responseEnvironmentName',
          input: 'input'
        },
        {
          label: '请求地址',
          prop: 'requestUrl',
          input: 'input'
        },
        {
          label: '请求接口编号',
          prop: 'requestInterfaceNo',
          input: 'input'
        },
        {
          label: '请求接口名称',
          prop: 'requestInterfaceName',
          input: 'input'
        },
        {
          label: '响应码',
          prop: 'responseCode',
          input: 'input'
        }
      ]
    },
    formConfig() {
      return [
        {
          prop: 'logNo',
          type: 'input',
          label: '日志流水号'
        },
        {
          prop: 'requestContent',
          type: 'textarea',
          label: '请求报文'
        },
        {
          prop: 'responseContent',
          type: 'textarea',
          label: '响应报文'
        }
      ]
    }
  },
  methods: {
    getInfoById(logNo) {
      this.$post('/v1/plApiRequestLog/selectPlApiRequestContentLogByLogNo', {
        logNo
      }).then(res => {
        this.form = res.data.item
        this.dialogModule.flag = true
      })
    },
    setdialog(data) {
      this.dialogModule.title = `日志报文信息`
      this.dialogModule.data = data
      this.getInfoById(data.logNo)
    },

    cbFun(res) {
      return { list: res.data.page.records, total: res.data.page.total }
    },
    async getTableData() {
      this.$refs.table.getTableData()
    }
  }
}
</script>

<style scoped>
</style>
